﻿@using XStudio.XCRF.Data.Entities.CureInfo
@model CureInfo
@{
    ViewBag.Title = "添加治疗信息";
    Layout = "~/Views/Shared/Master.cshtml";
}
@{Html.Telerik().Window().Name("CureInfoAddWindouw").Title("添加治疗信息").HtmlAttributes(new { @class = "ContentLargeWindow" })
    .Buttons(buttons => buttons.Clear())
    .Content(
@<text>
@{using (Ajax.BeginForm<CureInfoController>(c => c.CureInfoAdd(null),
   new AjaxOptions { OnBegin = "BeforeSend", OnSuccess = "OnSuccess", OnFailure = "OnError" }))
   {
<table>
    <tr>
        <th>治疗时间：</th>
        <td>
            @Html.HiddenFor(model => model.ID)
            @Html.HiddenFor(model => model.CRFID)
            @Html.DateEditorFor(model => model.Time)
        </td>
    </tr>
</table>
<input type="submit" value="提交" />
   }
  }
 </text>).Render();
}
@{Html.Telerik().Window().Modal(true).Visible(false)
    .Name("adding").Title("系统提示")
    .Buttons(buttons => buttons.Clear())
    .ClientEvents(window => window.OnOpen("OnAddingOpen"))
    .Content(
@<text>
正在添加，请稍后...
</text>)
    .Render();
}
@{Html.Telerik().Window().Modal(true).Visible(false)
    .Name("addError").Title("系统提示")
    .Buttons(buttons => buttons.Close())
    .ClientEvents(window => window.OnOpen("OnAddErrorOpen"))
    .Content(
@<text>
出现错误，请重试！
</text>)
    .Render();
}
<script type="text/javascript">
    function OnAddingOpen() {
        $("#adding").data("tWindow").center();
    }
    function OnAddErrorOpen() {
        $("#addError").data("tWindow").center();
    }
    function BeforeSend() {
        $("#adding").data("tWindow").open();
    }
    function OnSuccess(data) {
        if (data.ID) {
            var url = "@(Url.Action<CureInfoController>(c => c.CureInfoEdit(Guid.Empty)))";
            url = url.replace("@Guid.Empty", data.ID);
            window.location = url;
        } else {
            $("#addError").data("tWindow").open();
            $("#adding").data("tWindow").close();
        }
    }
    function OnError() {
        $("#addError").data("tWindow").open();
        $("#adding").data("tWindow").close();
    }
</script>